package org.ruanjj.removeelements;

import org.ruanjj.linkedlist.ListNode;

public class Solution {
    public ListNode removeElements(ListNode head, int val) {
        ListNode cur = new ListNode(-1);
        ListNode pre = cur;
        if(head == null){
            return head;
        }
        if(head.val != val){
            cur.next = head;
            cur = cur.next;
        }

        cur.next = removeElements(head.next,val);
        cur = cur.next;
        return pre.next;
    }
}
